package onlinebanking.client.gui;

import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JButton;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class StatementOfAccountPanel extends javax.swing.JPanel {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JLabel StatementOfAccountLabel;
	private JScrollPane jScrollPane1;
	private JButton ViewTransactionDetailsButton;
	private JTable TransactionHistory;
	
	DefaultTableModel TransactionHistoryModel;
	private ClientPanel parent;
	
	
	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new StatementOfAccountPanel());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public StatementOfAccountPanel() {
		super();
		initGUI();
	}
	
	public StatementOfAccountPanel(ClientPanel parent) {
		super();
		this.parent = parent;
		initGUI();
		sendCommand();
	}
	
	private void initGUI() {
		try {
			{
				this.setLayout(null);
				this.setBounds(0, 0, 582, 444);
				this.setPreferredSize(new java.awt.Dimension(582, 444));
				{
					StatementOfAccountLabel = new JLabel();
					this.add(StatementOfAccountLabel);
					StatementOfAccountLabel.setText("Statement Of Account");
					StatementOfAccountLabel.setBounds(0, 6, 158, 25);
				}
				{
					jScrollPane1 = new JScrollPane();
					this.add(jScrollPane1);
					jScrollPane1.setBounds(12, 43, 558, 341);
					jScrollPane1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					{
						TransactionHistoryModel = new DefaultTableModel(){ @Override
						    public boolean isCellEditable(int row, int column) {
						       //all cells false
						       return false;
						    }
							
						};
						TransactionHistoryModel.addColumn("ID");
						TransactionHistoryModel.addColumn("Type");
						TransactionHistoryModel.addColumn("Account #");
						TransactionHistoryModel.addColumn("Owner");
						TransactionHistoryModel.addColumn("Expiry");
						TransactionHistoryModel.addColumn("Processed");
						
						
						TransactionHistory = new JTable();
						jScrollPane1.setViewportView(TransactionHistory);
						TransactionHistory.setModel(TransactionHistoryModel);
						TransactionHistory.setBounds(12, 43, 558, 250);
					}
				}
				{
					ViewTransactionDetailsButton = new JButton();
					this.add(ViewTransactionDetailsButton);
					ViewTransactionDetailsButton.setText("View Transaction");
					ViewTransactionDetailsButton.setBounds(435, 396, 135, 22);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void sendCommand(){
		JOptionPane.showMessageDialog(null, "implement ing statement of acount panel");
	}
	
	public void addRow(String transactionid,String accountno, String transactiontype,
			String ammount, String initiatedby, String expiry){
		this.addRow(new Object[]{transactionid,accountno,transactiontype,ammount,initiatedby,expiry});
//		JTextArea textArea = (JTextArea)PendingTransactionsTable.getEditorComponent();
//		textArea.setEditable(false);  
//		PendingTransactionsTable.setCellSelectionEnabled(false);
//		PendingTransactionsTable.setFocusable(true);
	}
	
	public void addRow(Object[] rowdata){
		TransactionHistoryModel.addRow(rowdata);
	}

}
